package com.chixing.entity.MongDB;

import lombok.Getter;
import lombok.Setter;

import org.springframework.data.annotation.CreatedDate;

import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class Reply {
    @Id
    private String id;
    private String postId;         // 主楼ID
    private String parentId;       // 父级（Post 或 Reply 的ID）
    private Long userId;
    private String userName;
    private String content;
    private LocalDateTime createTime;
    private Integer isDeleted;

    // Tree结构字段（方案3的关键）
    private List<String> path;     // 用于快速构建树和排序
    private Integer level;         // 楼层层级：0=对主楼回复，1=对回复的回复...

    // 可保留业务字段（你需要的）
    private Long hotelId;
    private Long orderId;

    // ---------- 临时字段，用于构建树形楼中楼 ----------
    @Transient
    private List<Reply> children = new ArrayList<>();

    public Reply() {
    }

    public Reply(String id, String postId, String parentId, Long userId, String content,
                 LocalDateTime createTime, Integer isDeleted, List<String> path,
                 Integer level, Long hotelId, Long orderId) {
        this.id = id;
        this.postId = postId;
        this.parentId = parentId;
        this.userId = userId;
        this.content = content;
        this.createTime = createTime;
        this.isDeleted = isDeleted;
        this.path = path;
        this.level = level;
        this.hotelId = hotelId;
        this.orderId = orderId;
        this.children = new ArrayList<>();
    }

    @Override
    public String toString() {
        return "Reply{" +
                "id='" + id + '\'' +
                ", postId='" + postId + '\'' +
                ", parentId='" + parentId + '\'' +
                ", userId=" + userId +
                ", content='" + content + '\'' +
                ", createTime=" + createTime +
                ", isDeleted=" + isDeleted +
                ", path=" + path +
                ", level=" + level +
                ", hotelId=" + hotelId +
                ", orderId=" + orderId +
                ", children=" + children +
                '}';
    }
}
